# encoding: utf-8
# @author: wangxin
# @software: garner
# @file: loginoutViews.py
# @time: 2025/2/20 10:51

from http.client import responses

from django.contrib.auth import logout
from django.http import JsonResponse
from django.shortcuts import redirect
from django.urls import reverse
from django.views import View


class loginoutView(View):
    def get(self, request):
        # 注销用户登录状态
        logout(request)

        # 重定向用户到首页
        responses = redirect(reverse('index'))

        # 删除用户登录状态的cookie
        responses.delete_cookie('is_login')
        responses.delete_cookie('username')

        # 返回重定向的响应
        return responses